#include <iostream>
#include <algorithm>
#include <vector>
#include <unordered_map>
using namespace std;
bool check(int limit,vector<int>& vecArr,int m){
	
	int cnt=0;
	for(int i=0;i<static_cast<int>(vecArr.size());++i){
		if(vecArr[i]<=limit){
			++cnt;
		}
		else{
			cnt+=vecArr[i]/limit;
			if(vecArr[i]%limit){
				++cnt;
			}
		}
	}
	return cnt<=m;
}
int main() {

	int n,m;
	int maxn=0;
	cin>>n>>m;
	unordered_map<int,int> has;
	for(int i=0;i<n;++i){
		int t;
		cin>>t;
		++has[t];
	}
	vector<int> vecArr;
	for(auto& item:has){
		vecArr.push_back(item.second);
		maxn=max(maxn,item.second);
	}
	
	if(static_cast<int>(vecArr.size())>m){
		cout<<-1<<endl;
		
		return 0;
	}
	
	int left=1,right=maxn;
	while(left<right){
		int mid=left+(right-left)/2;
		if(check(mid,vecArr,m)){
			right=mid;
		}
		else{
			left=mid+1;
		}
	}
	cout<<left<<endl;
	
	return 0;
}
